import request from '@/utils/request';

/**
 * 分页查询海运散货地址库
 */
export async function pageOceanBulkCargoAddress(params) {
  const res = await request.get('/ocean/oceanBulkCargoAddress/page', { params });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 查询海运散货地址库列表
 */
export async function listOceanBulkCargoAddress(params) {
  const res = await request.get('/ocean/oceanBulkCargoAddress', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


/**
 * 返回海运散货地址库select列表
 */
export async function listOceanBulkCargoAddressSel(params) {
  const res = await request.get('/ocean/oceanBulkCargoAddress/listSel', { params });
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 根据id查询海运散货地址库
 */
export async function getOceanBulkCargoAddress(id) {
  const res = await request.get('/ocean/oceanBulkCargoAddress/' + id);
  if (res.data.code === 0 && res.data.data) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 添加海运散货地址库
 */
export async function addOceanBulkCargoAddress(data) {
  const res = await request.post('/ocean/oceanBulkCargoAddress', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改海运散货地址库
 */
export async function updateOceanBulkCargoAddress(data) {
  const res = await request.put('/ocean/oceanBulkCargoAddress', data);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除海运散货地址库
 */
export async function removeOceanBulkCargoAddress(id) {
  const res = await request.delete('/ocean/oceanBulkCargoAddress/' + id);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
